package com.universalInterface.lims_interface.service.impl;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import com.universalInterface.common.exception.BusinessException;
import com.universalInterface.lims_interface.common.constants.DateTimeConstant;
import com.universalInterface.lims_interface.entity.*;
import com.universalInterface.lims_interface.mapper.TestApiMapper;
import com.universalInterface.lims_interface.service.*;
import com.universalInterface.lims_interface.vo.api.LabChannelCsVo;
import com.universalInterface.lims_interface.vo.api.TestChannelCsVo;
import com.universalInterface.lims_interface.vo.api.TestConclusionParamVos;
import com.universalInterface.lims_interface.vo.api.TestCurveTableCsVo;
import com.universalInterface.lims_interface.vo.api.param.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Slf4j
@RequiredArgsConstructor
@Service
public class ExternalDataApiServiceImpl implements IExternalDataApiService {

	private final IInterfaceUserService userService;

	private final ILabInfoService iLabInfoService;

	private final ILabChannelService iLabChannelService;

	private final ITestInfoService iTestInfoService;

	private final ITestChannelService iTestChannelService;

	private final ITestCurveTableService iTestCurveTableService;

	private final ITestReportService iTestReportService;

	private final ITestConclusionService iTestConclusionService;

	private final TestApiMapper testApiMapper;

	// @Transactional(rollbackFor = Exception.class)
	@Override
	public String createSpace(CreateSpaceParam param) {
		// 登录验证
		InterfaceUser user = new InterfaceUser();
		user.setUserName(param.getUser());
		user.setPassWord(param.getPassword());
		user.setInterfaceType("1");
		user.setForm("1");
		user = userService.login(user);
		// 新增实验室
		LabInfo entity = new LabInfo();
		entity.setLabName(param.getName());
		entity.setLabType(param.getType());
		entity.setChNum(param.getChNum());
		LabInfo labInfo = iLabInfoService.save(entity);
		return labInfo.getLabNum();
	}

	@Override
	public String createSpaceChannel(CreateSpaceChannelParam param) {
		// 登录验证
		InterfaceUser user = new InterfaceUser();
		user.setUserName(param.getUser());
		user.setPassWord(param.getPassword());
		user.setInterfaceType("1");
		user.setForm("1");
		user = userService.login(user);
		// 验证JSON格式和数据
		List<LabChannelCsVo> labChannelCsVoList = JSONArray.parseArray(param.getChannel(), LabChannelCsVo.class);
		if (CollectionUtil.isEmpty(labChannelCsVoList)) {
			throw new BusinessException(500, "json数据为空");
		}
		// 判断json中的通道名称不为空
		List<LabChannelCsVo> c = labChannelCsVoList.stream().filter(x -> StrUtil.isBlank(x.getChName())).collect(Collectors.toList());
		if (CollectionUtil.isNotEmpty(c)) {
			throw new BusinessException(500, "json中的通道名称存在空的数据");
		}
		// 查询实验室是否存在
		LabInfo entity = new LabInfo();
		entity.setLabNum(param.getLabNum());
		LabInfo labInfo = iLabInfoService.get(entity);
		if (labInfo == null) {
			throw new BusinessException(500, "实验室数据不存在");
		}
		// 验证传入JSON的个数与实验室通道数量是否一致
		if (!labInfo.getChNum().equals(labChannelCsVoList.size())) {
			throw new BusinessException(500, "传入的通道JSON中的通道数量与实验室通道数量错误");
		}
		List<LabChannel> labChannelList = BeanUtil.copyToList(labChannelCsVoList, LabChannel.class);
		// 批量新增实验室通道
		for (int i = 0; i < labChannelList.size(); i++) {
			LabChannel labChannel = labChannelList.get(i);
			labChannel.setLabGuid(labInfo.getLabGuid());
			// 实验室通道fieldName的生成
			labChannel.setFieldName("F" + i);
		}
		Integer i = iLabChannelService.saveBatch(labChannelList);
		// 创建表
		String t1 = labInfo.getLabNum() + "TestData";
		String t2 = labInfo.getLabNum() + "TestChannel";
		String t3 = labInfo.getLabNum() + "TestCurveTable";
		// 查询数据库中实时表（3个）是否存在
		List<String> list = testApiMapper.listTable(labInfo.getLabNum());
		if (CollectionUtil.isNotEmpty(list) || list.size() > 0) {
			throw new BusinessException(500, "实验室的实时数据表已经被初始化");
		}
		// 创建实验室的实时数据表，表名=实验室编号+TestData
		// 创建实验室的实时数据通道信息表，表名=实验室编号+TestChannel
		// 创建实验室的实时曲线参数表，表名=实验室编号+TestCurveTable
		testApiMapper.createTableForTestData(t1, labChannelList);
		testApiMapper.createTableOfAs(t2, "test_channel");
		testApiMapper.createTableOfAs(t3, "test_curve_table");
		return "成功";
	}

	@Override
	public String getTestNum(GetTestNumParam param) {
		// 登录验证
		InterfaceUser user = new InterfaceUser();
		user.setUserName(param.getUser());
		user.setPassWord(param.getPassword());
		user.setInterfaceType("1");
		user.setForm("1");
		user = userService.login(user);
		//  查询实验室是否存在
		LabInfo entity = new LabInfo();
		entity.setLabName(param.getName());
		LabInfo labInfo = iLabInfoService.get(entity);
		if (labInfo == null) {
			throw new BusinessException(500, "实验室数据不存在");
		}
		return labInfo.getLabNum();
	}

	@Override
	public String updateSpace(UpdateSpaceParam param) {
		// 登录验证
		InterfaceUser user = new InterfaceUser();
		user.setUserName(param.getUser());
		user.setPassWord(param.getPassword());
		user.setInterfaceType("1");
		user.setForm("1");
		user = userService.login(user);
		// 验证JSON格式和数据
		List<LabChannelCsVo> labChannelCsVoList = JSONArray.parseArray(param.getChannel(), LabChannelCsVo.class);
		if (CollectionUtil.isEmpty(labChannelCsVoList)) {
			throw new BusinessException(500, "json数据为空");
		}
		// 判断json中的通道名称不为空
		List<LabChannelCsVo> c = labChannelCsVoList.stream().filter(x -> StrUtil.isBlank(x.getChName())).collect(Collectors.toList());
		if (CollectionUtil.isNotEmpty(c)) {
			throw new BusinessException(500, "json中的通道名称存在空的数据");
		}
		// 查询实验室是否存在
		LabInfo entity = new LabInfo();
		entity.setLabNum(param.getLabNum());
		LabInfo labInfo = iLabInfoService.get(entity);
		if (labInfo == null) {
			throw new BusinessException(500, "实验室数据不存在");
		}
		// 更新实验室通道数量
		labInfo.setChNum(labChannelCsVoList.size());
		iLabInfoService.updateById(labInfo);
		// 删除通道表中对应该实验室的数据
		LabChannel labChannel = new LabChannel();
		labChannel.setLabGuid(labInfo.getLabGuid());
		Integer i2 = iLabChannelService.delete(labChannel);
		// 批量新增实验室通道
		List<LabChannel> labChannelList = BeanUtil.copyToList(labChannelCsVoList, LabChannel.class);
		for (int i = 0; i < labChannelList.size(); i++) {
			LabChannel channel = labChannelList.get(i);
			channel.setLabGuid(labInfo.getLabGuid());
			// 实验室通道fieldName的生成
			channel.setFieldName("F" + i);
		}
		Integer i = iLabChannelService.saveBatch(labChannelList);
		// 清空实时通道信息表 TestChannel
		String t1 = labInfo.getLabNum() + "TestChannel";
		testApiMapper.truncateByTable(t1);
		// 存在就删表
		t1 = labInfo.getLabNum() + "TestData";
		testApiMapper.dropTableForExists(t1);
		// 重新创建实时数据表 TestData
		testApiMapper.createTableForTestData(t1, labChannelList);
		return "成功";
	}

	@Override
	public String getTestId(GetTestIdParam param) {
		// 登录验证
		InterfaceUser user = new InterfaceUser();
		user.setUserName(param.getUser());
		user.setPassWord(param.getPassword());
		user.setInterfaceType("1");
		user.setForm("1");
		user = userService.login(user);
		// 查询实验室是否存在
		LabInfo entity = new LabInfo();
		entity.setLabNum(param.getLabNum());
		LabInfo labInfo = iLabInfoService.get(entity);
		if (labInfo == null) {
			throw new BusinessException(500, "实验室数据不存在");
		}
		// 查询该实验室下最新试验的的试验Id
		TestInfo testInfo = iTestInfoService.newestInfos(labInfo.getLabGuid());
		if (testInfo == null) {
			throw new BusinessException(500, "实验室下没有试验信息");
		}
		return testInfo.getTestGuid().toString();
	}

	@Override
	public String testChannel(TestChannelParam param) {
		// 登录验证
		InterfaceUser user = new InterfaceUser();
		user.setUserName(param.getUser());
		user.setPassWord(param.getPassword());
		user.setInterfaceType("1");
		user.setForm("1");
		user = userService.login(user);
		// 验证JSON格式和数据
		List<TestChannelCsVo> testChannelCsVoList = JSONArray.parseArray(param.getRtChannel(), TestChannelCsVo.class);
		if (CollectionUtil.isEmpty(testChannelCsVoList)) {
			throw new BusinessException(500, "json数据为空");
		}
		// 判断json中的通道名称不为空
		List<TestChannelCsVo> c = testChannelCsVoList.stream().filter(x -> StrUtil.isBlank(x.getChName())).collect(Collectors.toList());
		if (CollectionUtil.isNotEmpty(c)) {
			throw new BusinessException(500, "json中的通道名称存在空的数据");
		}
		// 查询实验室是否存在
		LabInfo entity = new LabInfo();
		entity.setLabNum(param.getLabNum());
		LabInfo labInfo = iLabInfoService.get(entity);
		if (labInfo == null) {
			throw new BusinessException(500, "实验室数据不存在");
		}
		// 判断实验室通道数量是否和json中的实时数据通道信息的数量相等
		if (!labInfo.getChNum().equals(testChannelCsVoList.size())) {
			throw new BusinessException(500, "json中实验室通道数量错误");
		}
		// 全量更新实时通道数据信息表中数据
		// 清空实时通道数据信息表的数据
		String t1 = labInfo.getLabNum() + "TestChannel";
		testApiMapper.truncateByTable(t1);
		// 新增实时通道数据信息表中数据
		List<TestChannel> l = BeanUtil.copyToList(testChannelCsVoList, TestChannel.class);
		l.stream().forEach(x -> x.setLabGuid(labInfo.getLabGuid()));
		Integer i = iTestChannelService.saveBatchByTable(t1, l);
		return "成功";
	}

	@Override
	public String reviseTest(ReviseTestParam param) {
		// 登录验证
		InterfaceUser user = new InterfaceUser();
		user.setUserName(param.getUser());
		user.setPassWord(param.getPassword());
		user.setInterfaceType("1");
		user.setForm("1");
		user = userService.login(user);
		// 验证JSON格式和数据
		List<TestCurveTableCsVo> testCurveTableCsVoList = JSONArray.parseArray(param.getTestCurve(), TestCurveTableCsVo.class);
		if (CollectionUtil.isEmpty(testCurveTableCsVoList)) {
			throw new BusinessException(500, "json数据为空");
		}
		// 判断json中的通道名称不为空
		List<TestCurveTableCsVo> c = testCurveTableCsVoList.stream().filter(x -> StrUtil.isBlank(x.getChName())).collect(Collectors.toList());
		if (CollectionUtil.isNotEmpty(c)) {
			throw new BusinessException(500, "json中的通道名称存在空的数据");
		}
		// 查询实验室是否存在
		LabInfo entity = new LabInfo();
		entity.setLabNum(param.getLabNum());
		LabInfo labInfo = iLabInfoService.get(entity);
		if (labInfo == null) {
			throw new BusinessException(500, "实验室数据不存在");
		}
		// 全量更新实时曲线参数表中数据
		// 清空实时通道数据信息表的数据（保证当前试验的信息只存在于实时曲线表中）
		String t1 = labInfo.getLabNum() + "TestCurveTable";
		testApiMapper.truncateByTable(t1);
		// 新增实时通道数据信息表中数据
		Integer i = iTestCurveTableService.saveBatchByTable(t1, BeanUtil.copyToList(testCurveTableCsVoList, TestCurveTable.class));
		return "成功";
	}

	@Override
	public String realTimeData(RealTimeDataParam param) {
		// 登录验证
		InterfaceUser user = new InterfaceUser();
		user.setUserName(param.getUser());
		user.setPassWord(param.getPassword());
		user.setInterfaceType("1");
		user.setForm("1");
		user = userService.login(user);
		// 验证JSON格式和数据，保持字段顺序
		List<Map> list = JSON.parseArray(param.getRtData(), Map.class, Feature.OrderedField);
		if (CollectionUtil.isEmpty(list)) {
			throw new BusinessException(500, "json数据为空");
		}
		// 查询实验室是否存在
		LabInfo entity = new LabInfo();
		entity.setLabNum(param.getLabNum());
		LabInfo labInfo = iLabInfoService.get(entity);
		if (labInfo == null) {
			throw new BusinessException(500, "实验室数据不存在");
		}
		// 判断实验室通道数量是否和json中的通道字段的数量相等
		String jsonString = JSONObject.toJSONString(JSONObject.toJSONString(list.get(0)));
		String[] split = jsonString.split(",");
		if (!labInfo.getChNum().equals(split.length - 1)) {
			throw new BusinessException(500, "json中实验室通道字段的数量错误");
		}
		// 批量新增实时数据表
		String t1 = labInfo.getLabNum() + "TestData";
		Integer i = this.saveBatchForTestData(t1, list);
		return "成功";
	}

	@Override
	public Integer saveBatchForTestData(String tableName, List<Map> list) {
		log.info("json结果2222：{}", list);
		// 动态拼接字段，确保字段顺序和对应的value一致，以及字段驼峰格式
		List<String> keys = new ArrayList<>();
		keys.add("id");
		keys.addAll(list.get(0).keySet());
		log.info("动态获取字段结果3333：{}", keys);
		// 动态拼接字符串SQL
		StringBuilder sql = new StringBuilder();
		for (int i = 0; i < list.size(); i++) {
			sql.append("(");
			sql.append(IdUtil.getSnowflakeNextId());
			sql.append(",");
			Object[] keysArr = list.get(i).keySet().toArray();
			for (int j = 0; j < keysArr.length; j++) {
				sql.append("'" + list.get(i).get(keysArr[j]).toString() + "'");
				if (j != keysArr.length - 1) {
					sql.append(",");
				}
			}
			sql.append(")");
			if (i != list.size() - 1) {
				sql.append(",");
			}
		}
		log.info("动态拼接字符串SQL结果4444：{}", sql);
		Integer i = testApiMapper.saveBatchForTestData(tableName, keys, sql.toString());
		return i;
	}

	@Override
	public String stopTest(StopTestParam param) {
		// 登录验证
		InterfaceUser user = new InterfaceUser();
		user.setUserName(param.getUser());
		user.setPassWord(param.getPassword());
		user.setInterfaceType("1");
		user.setForm("1");
		user = userService.login(user);
		// 查询实验室是否存在
		LabInfo entity = new LabInfo();
		entity.setLabNum(param.getLabNum());
		LabInfo labInfo = iLabInfoService.get(entity);
		if (labInfo == null) {
			throw new BusinessException(500, "实验室数据不存在");
		}
		// 查询该实验室下最新试验的的试验Id
		TestInfo testInfo = iTestInfoService.newestInfos(labInfo.getLabGuid());
		if (testInfo == null) {
			throw new BusinessException(500, "实验室下没有试验信息");
		}
		// 更新试验结束时间和电量
		TestInfo info = new TestInfo();
		info.setId(testInfo.getId());
		info.setEndTime(param.getEndTime());
		info.setElectricity(String.valueOf(param.getEndElectricity()));
		Integer i = iTestInfoService.updateById(info);
		// 创建新表并复制实时数据到新表上（试验结束则为历史数据）
		String t1 = labInfo.getLabNum() + "TestData";
		String t2 = "No-" + testInfo.getId() + "TestData";
		String t3 = labInfo.getLabNum() + "TestChannel";
		String t4 = "No-" + testInfo.getId() + "TestChannel";
		String t5 = labInfo.getLabNum() + "TestCurveTable";
		String t6 = "No-" + testInfo.getId() + "TestCurveTable";
		// 查询试验的历史实时表（3个）是否存在
		List<String> list = testApiMapper.listTable("No-" + testInfo.getId());
		if (CollectionUtil.isNotEmpty(list) || list.size() > 0) {
			throw new BusinessException(500, "试验已经停止过，无法再次停止");
		}
		// 复制实时数据至历史数据 TestData TestChannel TestCurveTable
		testApiMapper.createTableOfAs(t2, t1);
		testApiMapper.createTableOfAs(t4, t3);
		testApiMapper.createTableOfAs(t6, t5);
		return "成功";
	}

	@Override
	public List<Object> createTestSpace(TestSpaceParam param) {
		InterfaceUser user = new InterfaceUser();
		user.setUserName(param.getUser());
		user.setPassWord(param.getPassword());
		user.setInterfaceType("1");
		user.setForm("1");
		user = userService.login(user);
		LabInfo labInfo = new LabInfo();
		labInfo.setLabNum(param.getLabNum());
		LabInfo labInfo1 = iLabInfoService.get(labInfo);
		if (labInfo1 == null) {
			throw new BusinessException(500, "该实验室不存在");
		}
//        判断穿过来的JSON是否是合格的
		JSONArray o = JSON.parseArray(param.getTestInfo());
		if (o.isEmpty()) {
			throw new BusinessException(500, "TestInfo的JSON数据为空");
		}
//        去掉首位的'['']'变为JSON对象
		String jsonTestInfo = param.getTestInfo().substring(1, param.getTestInfo().length() - 1);
//        JSON字符串转换为JSONObject
		JSONObject testObj = JSON.parseObject(jsonTestInfo);
		if (StrUtil.isBlank(testObj.get("ExperimentName").toString())) {
			throw new BusinessException(500, "试验名称不为空");
		}
		if (StrUtil.isBlank(testObj.get("StartTime").toString())) {
			throw new BusinessException(500, "试验开始测试时间不为空");
		}
		if (StrUtil.isBlank(testObj.get("Electricity").toString())) {
			throw new BusinessException(500, "试验电量不为空");
		}
		if (StrUtil.isBlank(testObj.get("isShow").toString())) {
			throw new BusinessException(500, "是否显示不为空");
		}
//        构造对象
		TestInfo testInfo1 = new TestInfo();
		testInfo1.setLabGuid(labInfo1.getLabGuid());
		testInfo1.setSampleName((String) testObj.get("SampleName"));
		if (StrUtil.isNotBlank(testObj.get("EndTime").toString())) {
			testInfo1.setEndTime(LocalDateTime.parse(testObj.get("EndTime").toString(), DateTimeConstant.YYYY_MM_DD_HH_MM_SS));
		}
		testInfo1.setProjectNo((String) testObj.get("ProjectNO"));
		testInfo1.setStaticP((String) testObj.get("StaticP"));
		testInfo1.setOdInletDb((String) testObj.get("ODInletDB"));
		testInfo1.setMachineType((String) testObj.get("MachineType"));
		testInfo1.setOdInletWb((String) testObj.get("ODInletWB"));
		testInfo1.setStartTime(LocalDateTime.parse(testObj.get("StartTime").toString(), DateTimeConstant.YYYY_MM_DD_HH_MM_SS));
		testInfo1.setElectricity((String) testObj.get("Electricity"));
		testInfo1.setTestOrderNo((String) testObj.get("TestOrderNO"));
		testInfo1.setNSampleNo((String) testObj.get("NSampleNO"));
		testInfo1.setEnergyEfficiency((String) testObj.get("energyEfficiency"));
		testInfo1.setTestNo((String) testObj.get("TestNO"));
		testInfo1.setCapacity((String) testObj.get("capacity"));
		testInfo1.setShows((Integer.valueOf((String) testObj.get("isShow"))));
		testInfo1.setElectricity((String) testObj.get("Electricity"));
		testInfo1.setExperimentName((String) testObj.get("ExperimentName"));
		testInfo1.setInspector((String) testObj.get("Inspector"));
		testInfo1.setPower((String) testObj.get("power"));
		testInfo1.setInspectionBatchNo((String) testObj.get("InspectionBatchNO"));
		testInfo1.setWSampleNo((String) testObj.get("WSampleNO"));
		testInfo1.setIdInletWb((String) testObj.get("IDInletWB"));
		testInfo1.setIdInletDb((String) testObj.get("IDInletDB"));
		iTestInfoService.add(testInfo1);
		iTestInfoService.clearTable(param.getLabNum());
		return o;
	}

	@Override
	public String reportUpload(ReportParam param) {

		Long testReportGuids = IdUtil.getSnowflakeNextId();
		InterfaceUser user = new InterfaceUser();
		user.setUserName(param.getUser());
		user.setPassWord(param.getPassword());
		user.setInterfaceType("1");
		user.setForm("1");
		user = userService.login(user);
		LabInfo labInfo = new LabInfo();
		labInfo.setLabNum(param.getLabNum());
		LabInfo labInfo1 = iLabInfoService.get(labInfo);
		if (labInfo1 == null) {
			throw new BusinessException(500, "该实验室不存在");
		}
		JSONArray r = JSON.parseArray(param.getTestReport());
		if (r.isEmpty()) {
			throw new BusinessException(500, "试验数据的JSON为空");
		}
		JSONArray c = JSON.parseArray(param.getTestConclusion());
		if (c.isEmpty()) {
			throw new BusinessException(500, "试验数据的结论和备注JSON为空");
		}
		TestInfo testInfons = iTestInfoService.newestInfos(labInfo1.getLabGuid());
		List<TestReportParamVo> testReportParamVos = JSONArray.parseArray(param.getTestReport(), TestReportParamVo.class);
//        List<TestReport> testReports = BeanUtil.copyToList(testReportParamVos, TestReport.class);
		ArrayList<TestReport> reportArrayList = new ArrayList<>();
		testReportParamVos.forEach(item -> {
			TestReport testReport = new TestReport();
			testReport.setTestReportGuid(testReportGuids);
			testReport.setTestGuid(testInfons.getTestGuid());
			testReport.setChannelUnit(item.getChannelUnit());
			testReport.setChannelName(item.getChannelName());
			testReport.setChannelValue1(item.getChannelValue1());
			testReport.setChannelValue2(item.getChannelValue2());
			testReport.setChannelValue3(item.getChannelValue3());
			testReport.setChannelValue4(item.getChannelValue4());
			testReport.setChannelValue5(item.getChannelValue5());
			testReport.setChannelValue6(item.getChannelValue6());
			testReport.setChannelValue7(item.getChannelValue7());
			testReport.setChannelValue8(item.getChannelValue8());
			reportArrayList.add(testReport);
		});
		iTestReportService.addBatch(reportArrayList);
		// 获取评论
		List<TestConclusionParamVos> testConclusionParamVos = JSON.parseArray(param.getTestConclusion(), TestConclusionParamVos.class);
		// 实体类类型转换
		List<TestConclusion> testConclusions = BeanUtil.copyToList(testConclusionParamVos, TestConclusion.class);
		// 取出对象实体
		TestConclusion ConclusionObj = testConclusions.get(0);
		// 传入GUID
		ConclusionObj.setTestReportGuid(testReportGuids);
		// 增加评论
		iTestConclusionService.add(ConclusionObj);
		return "成功";
	}

	// public static void main(String[] args) {
	// 	String s = "[{\"ChannelName\":\"\",\"EnglishName\":\"I.D.DB\"},{\"ChannelName\":\"室内湿球温度\",\"EnglishName\":\"I.D.WB\"}]";
	// 	List<LabChannelCsVo> labChannelCsVoList = JSONArray.parseArray(s, LabChannelCsVo.class);
	// 	List<LabChannelCsVo> collect = labChannelCsVoList.stream().filter(x -> StrUtil.isBlank(x.getChName())).collect(Collectors.toList());
	// 	System.out.println(collect.toString());
	//
	// 	String s1 = "2022-12-09 09:30:30";
	// 	DateTimeFormatter YEAR_MONTH_DAY = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
	// 	LocalDateTime parse = LocalDateTime.parse(s1, YEAR_MONTH_DAY);
	// 	LocalDateTime startTime = parse;
	// 	System.out.println(startTime);
	//
	// 	String s2 = "[{\"TestTime\":\"2022-08-30 15:35:25\",\"F1\":\"1\",\"F2\":\"2\",\"F3\":\"3\",\"F4\":\"4\",\"F5\":\"5\",\"F6\":\"6\",\"F7\":\"7\",\"F8\":\"8\",\"F9\":\"9\",\"F10\":\"10\"}]";
	// 	JSONArray jsonArray = JSONArray.parseArray(s2);
	// 	if (jsonArray.isEmpty()) {
	// 		System.out.println("json数据为空");
	// 	} else {
	// 		System.out.println("json数据不为空");
	// 		System.out.println(jsonArray.toJSONString());
	// 		String jsonString = JSONObject.toJSONString(JSONObject.toJSONString(jsonArray.get(0)));
	// 		System.out.println(jsonString);
	// 		String[] split = jsonString.split(",");
	// 		System.out.println(split.length);
	// 	}
	// }

}
